package com.kaifamiao.demo.d0825;


import java.time.Month;
import java.util.Comparator;

public class Demo {

    public static void main(String[] args) {
        /*
                数据类型：基本数据类型(原始类型)
                        引用数据类型： 类、接口、数组、enum(枚举)
                switch 表达式可以使用的类型： byte short int char String enum(枚举)
                枚举类  Month  DayOfWeek
         */
        // Object 对象， 创建 Object 类的实例
//      Object obj = new Object();

        Week week = Week.Monday;
//        week = Week.Tuesday;
//        week = Week.Wednesday;

        Week week1 = Week.Monday;

        System.out.println(week == week1);

//        A a = new A("aaa");
        A a = A.Spring;
        A b = A.Spring;
        System.out.println(a.getStr());
        System.out.println(a == b);

        Season season = Season.Summer;
        System.out.println(season.getText());

        System.out.println(season.getName());
        System.out.println(season.getIndex());

        Season season1 = Season.valueOf("Spring");
        System.out.println(season1);


        Season[] seasons = Season.values();
        for (Season s : seasons){
            System.out.println(s);
        }
    }
}

enum Week {
    /*
     枚举常量, 枚举常量定义了枚举类的一个 实例(对象)。
     每一个枚举常量都是独一无二的，在内存中只有一个实例, 多次调用都是同一个对象
     */
    Monday, Tuesday, Wednesday;

    Week(){
        System.out.println("week");
    }
}

enum Season {
    /*
     枚举常量, 枚举常量定义了枚举类的一个 实例(对象)。
     每一个枚举常量都是独一无二的，在内存中只有一个实例, 多次调用都是同一个对象
     */
    Spring("春天"), Summer, Autumn("秋天"), Winter("冬天");

    Season(){}

    Season(String text){
        this.text = text;
    }

    private String text;

    public String getText(){
        return text;
    }

    public String getName(){
        return super.name();
    }

    public int getIndex(){
        return super.ordinal();
    }

}


class A {
    public static final A Spring = new A("春天");
    public static final A Summer = new A();

    private String str;

    public A(){}
    public A(String str){
        this.str = str;
    }

    public String getStr(){
        return this.str;
    }
}
